import request from '@neu/biz-core/utils/request'
const baseUrl = 'dcam/api/w/fixed/assetType'

export const list = (params) => {
  return request({
    url: baseUrl,
    params,
    method: 'get'
  })
}

export const page = (params) => {
  return request({
    url: baseUrl + '/p',
    params,
    method: 'get'
  })
}

export const create = (data) => {
  return request({
    url: baseUrl,
    data,
    method: 'post'
  })
}

export const remove = (id) => {
  return request({
    url: baseUrl + '/' + id,
    method: 'delete'
  })
}

export const detail = (id) => {
  return request({
    url: baseUrl + '/' + id,
    method: 'get'
  })
}

export const update = (id, data) => {
  return request({
    url: baseUrl + '/' + id,
    data,
    method: 'put'
  })
}

export const tree = (belongs, categories) => {
  let url = baseUrl + '/tree'
  if (belongs === 'kj') {
    const code = categories === '3' ? 'xh' : 'kj'
    url = baseUrl + '/' + code + '/tree'
  } else if (belongs === 'sl') {
    const code = categories ? (categories === '1' ? '1601' : (categories === '2' ? '140' : 'xh')) : 'sl'
    url = baseUrl + '/' + code + '/tree'
  }
  return request({
    url: url,
    method: 'get'
  })
}
